 //UserComponent.h : Declaration of the CUserComponent

#pragma once
#include "resource.h"       // main symbols

#include "MMC.h"
#include "atlsnap.h"
#include "SnapIn.h"

#include "MMC_2_0_i.h"
//CUserComponent

class CSnapIn;


class CUserComponent : public CComObjectRootEx<CComSingleThreadModel>,
	public CSnapInObjectRoot<2, CSnapIn >,
	public IExtendPropertySheetImpl<CUserComponent>,
	public IExtendContextMenuImpl<CUserComponent>,
	public IExtendControlbarImpl<CUserComponent>,
	public IComponentImpl<CUserComponent>
{
public:
BEGIN_COM_MAP(CUserComponent)
	COM_INTERFACE_ENTRY(IComponent)
    COM_INTERFACE_ENTRY(IExtendPropertySheet)
    COM_INTERFACE_ENTRY(IExtendContextMenu)
    COM_INTERFACE_ENTRY(IExtendControlbar)
END_COM_MAP()

public:
	CUserComponent():m_ipDisplayHelp(NULL)
	{
	}

	STDMETHOD(Initialize)(LPCONSOLE lpConsole)
	{
		HRESULT hr=IComponentImpl<CUserComponent>::Initialize(lpConsole);
		_ASSERT( S_OK == hr );
		hr = m_spConsole->QueryInterface(IID_IDisplayHelp, (void **)&m_ipDisplayHelp);
		_ASSERT( S_OK == hr );
		return hr;
	}
	
	STDMETHOD(Destroy)(long cookie)
	{
		if (m_ipDisplayHelp) 
		{
			m_ipDisplayHelp->Release();
			m_ipDisplayHelp = NULL;
		}
		HRESULT hr=IComponentImpl<CUserComponent>::Destroy(cookie);
		return hr;
	}

	STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param)
	{
		if (lpDataObject != NULL)
			return IComponentImpl<CUserComponent>::Notify(lpDataObject, event, arg, param);

		return E_NOTIMPL;
	}

	IDisplayHelp* m_ipDisplayHelp;
};

